package tmproject.hlhj.fhp.anwser.activitys

import android.graphics.Bitmap
import android.graphics.Color
import android.util.Log
import android.webkit.WebView
import android.webkit.WebViewClient
import com.tenma.ventures.bean.utils.TMSharedPUtil
import kotlinx.android.synthetic.main.aty_web.*
import tmproject.hlhj.fhp.anwser.BaseAty
import tmproject.hlhj.fhp.anwser.Contents
import tmproject.hlhj.fhp.anwser.R
import tmproject.hlhj.fhp.anwser.http.Urls
import tmproject.hlhj.fhp.anwser.utils.SPHelper

/**
 * Created by Never Fear   on 2018\8\30 0030.
Never More....
 */
class WebAty :BaseAty() {
    override fun despatchData() {
    }

    override fun setListener() {
        btExit.setOnClickListener {
            finish()
        }
    }

    override fun initView() {
        val color = TMSharedPUtil.getTMThemeColor(this)
        if (null!=color&&color.isNotEmpty()){
            loBack.setBackgroundColor(Color.parseColor(color))
        }
        webView.settings.javaScriptEnabled=true
        webView.settings.domStorageEnabled=true
        webView.webViewClient=object :WebViewClient(){
            override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
                Log.e("fhp","载入的Url${url}")
                super.onPageStarted(view, url, favicon)
            }
        }
        val type = intent.getIntExtra("type", -1)
        if (type==1){
            webView.loadUrl(Urls.DrawUrl+"?token=${SPHelper.getToken(this@WebAty)}"+Urls.sign+"demo")

        }else if (type==2){
            webView.loadUrl(Urls.DrawUrl+"?token=${SPHelper.getToken(this@WebAty)}"+Urls.sign)
        }
        Log.e("fhp","载入的Url${Urls.DrawUrl+"?token=${SPHelper.getToken(this@WebAty)}"+Urls.sign}")
    }

    override fun getContentId(): Int {
        return R.layout.aty_web
    }
}